package com.paad.todolist;

import java.util.*;

enum squad_image{
	swordsmen,
	archers,
	cavalry
}

public class Squad {
	String name;
	String squadType;
	squad_image img;
	int currentUnits;
	int squadPoints;
	ArrayList<Unit> units;
	double lowSpeed;
	double range;
	int lowDef;
	int numTotalUnits;
	int id;
	boolean team; // blue is true, red is false
	boolean hasActed;
	boolean hasMoved;
	
	public Squad(){
		name = "Basic Riflemen";
		units = new ArrayList<Unit>();
		for(int i = 0; i < 8; i++){
			units.add(new Unit());
		}
		lowSpeed = 2.5;
		range = 1.5;
		lowDef = 4;
		img = squad_image.swordsmen;
		team = true;
		hasActed = false;
		hasMoved = false;
		currentUnits = numTotalUnits = units.size();
	}
	
	public Squad(String type){
		squadType = type;
		init(type);
	}
	
	public Squad(String type, boolean _team){
		squadType = type;
		init(type);
		team = _team;
	}
		
	void init (String type)
	{
		if(type.equals("swordsmanA")){
			name = "swordsmen";
			currentUnits = numTotalUnits = 4;
			units = new ArrayList<Unit>();
			for(int i = 0; i < 5; i++){
				units.add(new Unit("swordsman"));
			}
			lowSpeed = 2.5;
			lowDef = 4;
			range = 1.5;
			img = squad_image.swordsmen;
			squadPoints = 1;
		}else if(type.equals("swordsmanB")){
			name = "swordsmen";
			currentUnits = numTotalUnits = 10;
			units = new ArrayList<Unit>();
			for(int i = 0; i < 12; i++){
				units.add(new Unit("swordsman"));
			}
			lowSpeed = 2.5;
			lowDef = 4;
			range = 1.5;
			img = squad_image.swordsmen;
			squadPoints = 2;
		}else if(type.equals("archerA")){
			name = "archers";
			currentUnits = numTotalUnits = 3;
			units = new ArrayList<Unit>();
			for(int i = 0; i < 3; i++){
				units.add(new Unit("archer"));
			}
			lowSpeed = 2;
			lowDef = 4;
			range = 4.0;
			img = squad_image.archers;
			squadPoints = 1;
		}else if(type.equals("archerB")){
			name = "archers";
			currentUnits = numTotalUnits = 7;
			units = new ArrayList<Unit>();
			for(int i = 0; i < 7; i++){
				units.add(new Unit("archer"));
			}
			lowSpeed = 2;
			lowDef = 4;
			range = 4.0;
			img = squad_image.archers;
			squadPoints = 2;
		}else if(type.equals("cavalry")){
			name = "cavalry";
			currentUnits = numTotalUnits = 5;
			units = new ArrayList<Unit>();
			for(int i = 0; i < 5; i++){
				units.add(new Unit("cavalry"));
			}
			lowSpeed = 4;
			lowDef = 5;
			range = 1.5;
			img = squad_image.cavalry;
			squadPoints = 2;
		}
		hasActed = false;
		hasMoved = false;
	}
	
	public void setId(int _id){
		id = _id;
	}
	
	public int getId(){
		return id;
	}
	
	public void setTeam(boolean tem){
		team = tem;
	}
	
	public void setName(String nm){
		name = nm;
	}
	
	public String getName(){
		return name;
	}
	
	
	void kill()
	{
		currentUnits --;
		units.remove(0);
	}
	
	boolean annihilated()
	{
		return currentUnits <= 0;
	}
}
